home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Files / Glob_Close.bsh < prev    next >
Encoding:
Text File  |  2004-08-29  |  940 b   |  49 lines

  1. /*
  2.  * Glob_Close.bsh - a BeanShell macro for jEdit that closes
  3.  * all open buffers matching a given glob pattern.
  4.  *
  5.  * Copyright (C) 2003-2004 Ollie Rutherfurd <oliver@rutherfurd.net>
  6.  *
  7.  * $Id: Glob_Close.bsh,v 1.1 2004/03/19 15:57:59 spestov Exp $
  8.  */
  9.  
  10. import gnu.regexp.*;
  11.  
  12. void globClose(View view)
  13. {
  14.     String glob = Macros.input(view, "Glob Pattern:");
  15.     if(glob == null || glob.length() == 0)
  16.         return;
  17.  
  18.     RE re = null;
  19.     try
  20.     {
  21.         re = new RE(MiscUtilities.globToRE(glob));
  22.     }
  23.     catch(Exception e)
  24.     {
  25.         Macros.error(view,"Error in glob pattern: " + e.toString());
  26.         return;
  27.     }
  28.  
  29.     Buffer[] buffers = jEdit.getBuffers();
  30.     for(int i=0; i < buffers.length; i++)
  31.     {
  32.         if(re.isMatch(buffers[i].getPath()))
  33.             jEdit.closeBuffer(view,buffers[i]);
  34.     }
  35. }
  36.  
  37. globClose(view);
  38.  
  39. /*
  40.  
  41. <listitem>
  42.     <para><filename>Glob_Close.bsh</filename></para>
  43.     <abstract><para>
  44.         Closes all open buffers matching a given glob pattern.
  45.     </para></abstract>
  46. </listitem>
  47.  
  48. */
  49.